import { Map } from "immutable";

import * as actionTypes from "./constants";

const defaultState = Map({
  tabList: [],
  currentIndex: 0,
  listInfo: []
});

function reducer(state = defaultState, action) {
  switch (action.type) {
    case actionTypes.CHANGE_TAB_LIST:
      return state.set("tabList", action.tabList);
    case actionTypes.CHANGE_CURRENT_INDEX:
      return state.set("currentIndex", action.index);
    case actionTypes.CHANGE_RANKING_LIST:
      return state.set("listInfo", action.listInfo);
    default:
      return state;
  }
};

export default reducer;